package com.qf.eureka;


import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;

@SpringBootApplication
@EnableWebSecurity
@EnableEurekaServer
public class OpenApiEurekaApp extends WebSecurityConfigurerAdapter {

    public static void main(String[] args) {
        SpringApplication.run(OpenApiEurekaApp.class,args);
    }


    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http.csrf().disable()
                .authorizeRequests()//开启请求认证配置
                .antMatchers("/eureka/**")//符合某个规则的路径
                .permitAll()//放行
                .antMatchers("/actuator/**")
                .permitAll()//
                .anyRequest()//
                .authenticated()//
                .and()//
                .httpBasic();
    }
}
